/*
 * GameFrame.java
 */
package othello.gui;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import othello.GUIC;
import othello.Othello;
import othello.logic.GameGrid;
import othello.logic.MoveQueue;

public class GameFrame extends JFrame{
    GameBoard gameBoard;
    GUIC guic;
    
    public GameFrame(GameGrid gameGrid, GUIC guic, Othello main) {
        this.guic = guic;
        
        this.getContentPane().setBackground(new Color(0x009900));
        gameBoard = new GameBoard(gameGrid);
        this.getContentPane().add(gameBoard, BorderLayout.CENTER);

        JPanel btnPanel = new JPanel();
        
        JButton btnNewGame = new JButton("Nytt Parti");
        btnPanel.add(btnNewGame);
        btnNewGame.addActionListener(main);
        
        
        JButton btnAvsluta = new JButton("Avsluta");
        btnPanel.add(btnAvsluta);
        btnAvsluta.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                System.exit(0);         //Close the program.
            }
        });


        this.getContentPane().add(btnPanel, BorderLayout.SOUTH);
        this.setTitle("Othello");
        this.setSize(487, 507);     //Matches the GameSquares.
        this.setResizable(false);
        //this.pack();
        this.setVisible(true);
        this.setLocationRelativeTo(null);
        this.setDefaultCloseOperation(EXIT_ON_CLOSE);
    }

    public void setNewGrid(GameGrid gameGrid){
        gameBoard.setNewGrid(gameGrid);
    }

    public void setNewMoveQueue(MoveQueue mq) {
        gameBoard.setNewMoveQueue(mq);
    }
}
